﻿using MediatR;
using ProcurementManagement.Applcation.Command.PurchaseReturnsCommand;
using ProcurementManagement.Domain.ProcurementDomain;
using ProcurementManagement.Infrstructre.Interface;

namespace ProcurementManagement.Applcation.CommandHanlers.PurchaseReturnsCommandHandler
{
    /// <summary>
    /// 反填实退采购款中介者
    /// </summary>
    public class FanDirectRefundCommandHandler:IRequestHandler<FanDirectRefundCommand, DirectRefund>
    {
        private readonly lnterfaceDirectRefundRepository _directRefundRepository;

        public FanDirectRefundCommandHandler(lnterfaceDirectRefundRepository directRefundRepository)
        {
            _directRefundRepository = directRefundRepository;
        }

        public async Task<DirectRefund> Handle(FanDirectRefundCommand request, CancellationToken cancellationToken)
        {
            return (await _directRefundRepository.GetAll()).Where(x => x.DirectRefundId == request.id).First();
        }
    }
}
